package com.eos.orm.mybatis.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.eos.orm.mybatis.dao.ReceiptListMapper;
import com.eos.orm.mybatis.model.ReceiptList;
import com.eos.orm.mybatis.model.ReceiptListExample;

/**
 * receipt_list签收货物清单表的CURD操作
 * 
 * @author sz
 * 
 */
public class ReceiptListMapperImpl extends AbstractSqlSessionFactory implements
		ReceiptListMapper {

	public int countByExample(ReceiptListExample example) {
		return 0;
	}

	public int deleteByExample(ReceiptListExample example) {
		return 0;
	}

	public int deleteByPrimaryKey(Integer id) {
		SqlSession session = sqlSessionFactory.openSession();
		try{
			ReceiptListMapper mapper = session.getMapper(ReceiptListMapper.class);
			mapper.deleteByPrimaryKey(id);
			session.commit();
			mapper = null;
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.ReceiptListMapperImpl.deleteByPrimaryKey throws exception:"
					+ e.getMessage());
			return -1;
		}finally{
			session.close();
		}
		return 0;
	}

	public int insert(ReceiptList record) {
		SqlSession session = sqlSessionFactory.openSession();
		try{
			ReceiptListMapper mapper = session.getMapper(ReceiptListMapper.class);
			mapper.insert(record);
			session.commit();
			mapper = null;
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.ReceiptListMapperImpl.insert throws exception:"
					+ e.getMessage());
			return -1;
		}finally{
			session.close();
		}
		return 0;
	}

	public int insertSelective(ReceiptList record) {
		return 0;
	}

	public List<ReceiptList> selectByExample(ReceiptListExample example) {
		List<ReceiptList> templist = new ArrayList<ReceiptList>();
		SqlSession session = sqlSessionFactory.openSession();
		try{
			ReceiptListMapper mapper = session.getMapper(ReceiptListMapper.class);
			templist = mapper.selectByExample(example);
			mapper = null;
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.ReceiptListMapperImpl.selectByExample throws exception:"
					+ e.getMessage());
		}finally{
			session.close();
		}
		return templist;
	}

	public ReceiptList selectByPrimaryKey(Integer id) {
		SqlSession session = sqlSessionFactory.openSession();
		try{
			ReceiptListMapper mapper = session.getMapper(ReceiptListMapper.class);
			return mapper.selectByPrimaryKey(id);
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.ReceiptListMapperImpl.selectByPrimaryKey throws exception:"
					+ e.getMessage());
		}finally{
			session.close();
		}
		return null;
	}

	public int updateByExample(ReceiptList record, ReceiptListExample example) {
		return 0;
	}

	public int updateByExampleSelective(ReceiptList record,
			ReceiptListExample example) {
		return 0;
	}

	public int updateByPrimaryKey(ReceiptList record) {
		return 0;
	}

	public int updateByPrimaryKeySelective(ReceiptList record) {
		SqlSession session = sqlSessionFactory.openSession();
		try{
			ReceiptListMapper mapper = session.getMapper(ReceiptListMapper.class);
			mapper.updateByPrimaryKeySelective(record);
			session.commit();
			mapper = null;
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.ReceiptListMapperImpl.updateByPrimaryKeySelective throws exception:"
					+ e.getMessage());
			return -1;
		}finally{
			session.close();
		}
		return 0;
	}

}
